//
//  UserCenterViewController.m
//  ROSE
//
//  Created by 艾阳 on 2018/5/22.
//  Copyright © 2018年 HeNanZhongDunYunAn. All rights reserved.
//

#import "UserCenterViewController.h"
#import "UCItemCell.h"
#import "UserDetailViewController.h"
#import "GenerateRoseViewController.h"
#import "TQROSTViewController.h"
#import "TQETHViewController.h"
#import "ETHChangeROSTViewController.h"

@interface UserCenterViewController ()<LMJNavUIBaseViewControllerDataSource,LMJElementsFlowLayoutDelegate>

@property (nonatomic,strong) UserHeaderView *userHeaderView;

@property (nonatomic,strong) NSArray *titleArray;
@property (nonatomic,strong) NSArray *iconArray;
@property (nonatomic,strong) NSArray *classArray;
@end

@implementation UserCenterViewController

- (NSArray *)titleArray{
    if (!_titleArray) {
        _titleArray = @[@"生成ROSE",@"ROST提取",@"ETH提取",@"ETH兑换ROST",@"实名认证",@"交易记录",@"钱包地址",@"爱情证书",@"退出"];
    }
    return _titleArray;
}

-(NSArray *)iconArray{
    if (!_iconArray) {
        _iconArray = @[@"00",@"00",@"00",@"00",@"00",@"00",@"00",@"00",@"00"];
    }
    return _iconArray;
}

- (NSArray *)classArray{
    if (!_classArray) {
        _classArray = @[@"GenerateRoseViewController",@"TQROSTViewController",@"TQETHViewController",@"ETHChangeROSTViewController"];
    }
    return _classArray;
}



- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.collectionView.backgroundColor = [UIColor whiteColor];
    self.title = @"我的";
    //headerView
    self.userHeaderView = [[UserHeaderView alloc]initWithFrame:CGRectMake(0, 0, size_width, 184)];
    [self.userHeaderView.detailBtn addTarget:self action:@selector(goUserDetail) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.userHeaderView];
    //collectionView
    [self changeCollectionViewFrame];
    [self.collectionView registerClass:[UCItemCell class] forCellWithReuseIdentifier:NSStringFromClass([UCItemCell class])];
    self.collectionView.scrollEnabled = NO;
    //dataRequest
    
}
#pragma mark - DataRequest

- (void)getUserInfo{
    
}

#pragma mark - collectionView
- (void)changeCollectionViewFrame
{
    UIEdgeInsets contentInset = self.collectionView.contentInset;
    /**
     减去headerview的位置
     */
    contentInset.top += 184;
    
    self.collectionView.contentInset = contentInset;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return 9;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    UCItemCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([UCItemCell class]) forIndexPath:indexPath];
    [cell.title setText:self.titleArray[indexPath.row]];
    [cell.icon setImage:[UIImage imageNamed:self.iconArray[indexPath.row]]];
    return cell;
}

/**
 跳转进详情页面
 */
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    [collectionView deselectItemAtIndexPath:indexPath animated:YES];
    [self.navigationController pushViewController:[[NSClassFromString(self.classArray[indexPath.row]) alloc]init] animated:YES];
    
    
}

/**
 Cell-Size
 */
- (CGSize)waterflowLayout:(LMJElementsFlowLayout *)waterflowLayout collectionView:(UICollectionView *)collectionView sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
    return CGSizeMake((size_width-40)/3,90);
}

- (UICollectionViewLayout *)collectionViewController:(LMJCollectionViewController *)collectionViewController layoutForCollectionView:(UICollectionView *)collectionView{
    
    LMJElementsFlowLayout * elementsFlowLayout = [[LMJElementsFlowLayout alloc] initWithDelegate:self];
    return elementsFlowLayout;
    
}


#pragma mark - hideBaseNav
- (BOOL)navUIBaseViewControllerIsNeedNavBar:(LMJNavUIBaseViewController *)navUIBaseViewController{
    return NO;
}

#pragma mark - EVENT
-(void)goUserDetail{
    UserDetailViewController * userDetailVc = [[UserDetailViewController alloc]init];
    [self.navigationController pushViewController:userDetailVc animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
